<?php

class Admin_Model_GallerySizesMapper {
	protected $_dbTable;
	public function setDbTable($dbTable)
    {
        if (is_string($dbTable)) {
            $dbTable = new $dbTable();
        }
        if (!$dbTable instanceof Zend_Db_Table_Abstract) {
            throw new Exception('Invalid table data gateway provided');
        }
        $this->_dbTable = $dbTable;
        return $this;
    }

    public function getDbTable()
    {
        if (null === $this->_dbTable) {
            $this->setDbTable('Admin_Model_DbTable_GallerySizes');
        }
        return $this->_dbTable;
    }
    
    public function find($id){
    	$t = $this->getDbTable();
    	$row = $t->fetchRow('Id='.$id);
        return new Admin_Model_GallerySizes($row->toArray());
    }
    
    public function fetchAll(){
    	$t = $this->getDbTable();
    	$set = $t->fetchAll(null,'Width');
    	$result = array();
    	foreach($set as $row){
    		$result[] = new Admin_Model_GallerySizes($row->toArray());
    	}
    	return $result;
    }
}

?>